<template>
  <el-card class="content-card" shadow="hover">
    <template #header>
      <div class="card-header">
        <span>API文档 - 概述</span>
      </div>
    </template>

    <div class="content-container">
      <div class="api-content">
        <div class="section" id="introduction">
          <div class="section-header"><h2>项目介绍</h2></div>
          <p class="intro-text">
            欢迎使用我们的API文档系统！这是一个功能强大、易于使用的API管理和文档展示平台，
            旨在帮助开发者快速理解和集成我们的服务。
          </p>
        </div>

        <div class="section" id="features">
          <div class="section-header"><h2>主要特性</h2></div>
          <div class="feature-grid">
            <div class="feature-item">
              <div class="feature-icon">📚</div>
              <h3>完整的API文档</h3>
              <p>提供详细的API接口说明、参数描述和示例代码</p>
            </div>
            <div class="feature-item">
              <div class="feature-icon">🚀</div>
              <h3>快速集成</h3>
              <p>简单易懂的集成指南，让您快速上手使用我们的服务</p>
            </div>
            <div class="feature-item">
              <div class="feature-icon">🔧</div>
              <h3>灵活配置</h3>
              <p>支持多种配置方式，满足不同场景的使用需求</p>
            </div>
            <div class="feature-item">
              <div class="feature-icon">💡</div>
              <h3>最佳实践</h3>
              <p>提供丰富的使用案例和最佳实践指导</p>
            </div>
          </div>
        </div>

        <div class="section" id="architecture">
          <div class="section-header"><h2>系统架构</h2></div>
          <p class="arch-description">
            我们的API系统采用现代化的微服务架构，具有高可用性、高性能和易扩展的特点。
            系统支持RESTful API规范，提供JSON格式的数据交换。
          </p>
          <div class="arch-features">
            <ul>
              <li><strong>高性能：</strong>优化的服务架构，确保快速响应</li>
              <li><strong>高可用：</strong>多节点部署，保证服务稳定性</li>
              <li><strong>安全性：</strong>完善的认证和授权机制</li>
              <li><strong>可扩展：</strong>模块化设计，支持功能扩展</li>
            </ul>
          </div>
        </div>

        <div class="section" id="getting-started">
          <div class="section-header"><h2>开始使用</h2></div>
          <p>要开始使用我们的API，请按照以下步骤：</p>
          <ol class="steps-list">
            <li>阅读<strong>快速开始</strong>指南，了解基本使用方法</li>
            <li>查看<strong>基础配置</strong>，完成必要的环境设置</li>
            <li>浏览<strong>API方法</strong>，选择您需要的接口</li>
            <li>参考<strong>使用案例</strong>，学习实际应用场景</li>
          </ol>
        </div>
      </div>

      <!-- 右侧悬浮目录 -->
      <div class="toc">
        <div class="toc-title">目录</div>
        <div class="toc-item" @click="scrollToSection('introduction')">
          项目介绍
        </div>
        <div class="toc-item" @click="scrollToSection('features')">
          主要特性
        </div>
        <div class="toc-item" @click="scrollToSection('architecture')">
          系统架构
        </div>
        <div class="toc-item" @click="scrollToSection('getting-started')">
          开始使用
        </div>
      </div>
    </div>
  </el-card>
</template>

<script setup>
const scrollToSection = (sectionId) => {
  const element = document.getElementById(sectionId);
  if (element) {
    element.scrollIntoView({ behavior: "smooth" });
  }
};
</script>

<style scoped>
.content-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.card-header {
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 500;
  color: #303133;
}

:deep(.el-card__body) {
  padding: 0;
  height: calc(100% - 60px);
  overflow-y: auto;
  background: #ffffff;
}

.content-container {
  min-height: 100%;
  padding: 30px;
  padding-right: 280px;
  background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
}

.api-content {
  max-width: 1000px;
  margin: 0 auto;
  line-height: 1.8;
  color: #4a5568;
}

.section {
  margin-bottom: 40px;
  padding: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section h2 {
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 2px solid #409eff;
  color: #303133;
  font-size: 20px;
  font-weight: 600;
  position: relative;
  flex: 1;
}

.section h2::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 50px;
  height: 2px;
  background: #409eff;
  border-radius: 1px;
}

.intro-text {
  font-size: 16px;
  line-height: 1.8;
  color: #4a5568;
  margin-bottom: 20px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.feature-item {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.feature-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.feature-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.feature-item h3 {
  margin: 0 0 12px 0;
  color: #2d3748;
  font-size: 18px;
  font-weight: 600;
}

.feature-item p {
  margin: 0;
  color: #4a5568;
  font-size: 14px;
  line-height: 1.6;
}

.arch-description {
  font-size: 16px;
  line-height: 1.8;
  color: #4a5568;
  margin-bottom: 20px;
}

.arch-features ul {
  list-style: none;
  padding: 0;
}

.arch-features li {
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 15px;
  line-height: 1.6;
}

.arch-features li:last-child {
  border-bottom: none;
}

.steps-list {
  padding-left: 20px;
}

.steps-list li {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.6;
}

/* 右侧悬浮目录样式 */
.toc {
  position: fixed;
  right: 50px;
  top: 50%;
  transform: translateY(-50%);
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  border: 1px solid #e4e7ed;
  min-width: 200px;
}

.toc-title {
  font-weight: 700;
  margin-bottom: 15px;
  color: #2d3748;
  font-size: 18px;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}

.toc-item {
  padding: 12px 16px;
  cursor: pointer;
  color: #4a5568;
  transition: all 0.3s ease;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 4px;
  border-left: 3px solid transparent;
  position: relative;
}

.toc-item:hover {
  color: #409eff;
  background: #ecf5ff;
  border-left-color: #409eff;
  transform: translateX(4px);
}

.toc-item:active {
  transform: translateX(2px);
}

/* 响应式设计 */
@media (max-width: 1400px) {
  .content-container {
    padding-right: 30px;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .content-container {
    padding: 20px 15px;
  }

  .section {
    padding: 20px 15px;
    margin-bottom: 25px;
  }

  .section h2 {
    font-size: 18px;
  }

  .card-header {
    font-size: 16px;
    padding: 15px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}

/* 滚动条样式 */
:deep(.el-card__body)::-webkit-scrollbar {
  width: 6px;
}

:deep(.el-card__body)::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

:deep(.el-card__body)::-webkit-scrollbar-thumb {
  background: #409eff;
  border-radius: 3px;
}

:deep(.el-card__body)::-webkit-scrollbar-thumb:hover {
  background: #337ecc;
}
</style>